/*************************************
 * Created by WebStorm
 * Author : 艾尼亚尔·毛拉吾提
 * QQ : 524155792  WeChat : ainiyar0124
 * Created Time :2024/2/5 18:47
 Desc :
 **************************************/
import {Config} from '@/config';
import {removeToken, removeTokenTime} from "@/util/Auth.ts";


export function checkStatus(code: number, msg: string = '') {
    const $message = window['$message'];
    switch (code) {
        case 500:
            $message.error('服务器错误,请联系管理员!');
            break;
        case 4012:
            const LoginPath = Config.BASE_LOGIN;
            $message.error(msg, {
                duration: 3000,
                onLeave() {
                    removeToken();
                    removeTokenTime();
                    window.location.href = LoginPath;
                }
            });
            break;
        default:
            $message.error(msg);
    }
}